<template>
	<el-card shadow="never" header="个人信息">
		<el-form ref="form" :model="form" label-width="120px" style="margin-top:20px;">
			<el-form-item label="账号">
				<el-input v-model="form.username" disabled></el-input>
				<div class="el-form-item-msg">账号信息用于登录，系统不允许修改</div>
			</el-form-item>
      <el-form-item label="姓名">
        <el-input v-model="form.realName"></el-input>
      </el-form-item>
      <el-form-item label="性别">
        <el-select v-model="form.gender" placeholder="请选择">
          <el-option  label="保密" value="0"></el-option>
          <el-option  label="男" value="1"></el-option>
          <el-option  label="女" value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="form.phone"></el-input>
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="form.email"></el-input>
      </el-form-item>
      <el-form-item label="所属机构">
        <el-input v-model="form.unit.name" disabled></el-input>
      </el-form-item>
      <el-form-item label="所属角色">
        <el-input v-model="role.roleName" disabled></el-input>
      </el-form-item>
			<el-form-item>
				<el-button type="primary" @click="updatePer">保存</el-button>
			</el-form-item>
		</el-form>
	</el-card>
</template>

<script>
	export default {
		data() {
			return {
				form: this.$TOOL.data.get('USER_INFO'),
        role :this.$TOOL.data.get('USER_CRT_ROLE')//当前角色
			}
		},

    created() {
      this.form.gender += ''
    },
    methods:{
      updatePer(){
        this.$API.auth.updatePersonal.post({
            id:this.form.id,
            realName:this.form.realName,
            phone:this.form.phone,
            email:this.form.email,
            gender:this.form.gender,
            avatar:this.form.avatar
        }).then((res)=>{
          this.$message.success(res.msg)
        })
      }
    }
  }
</script>

<style>
</style>
